package main

import (
	"fmt"
	"io"
	"net"
)

const (
	Addr = ":1234"
)

func startEchoServer(addr string) {
	lis, err := net.Listen("tcp4", addr)
	if err != nil {
		fmt.Println("Failed to Start Server:", err)
		return
	} else {
		fmt.Println("Start Server At:", addr)
	}
	defer lis.Close()

	for {
		conn, err := lis.Accept()
		if err != nil {
			fmt.Println("Failed to Accept Connect:", err)
			return
		}
		go func() {
			io.Copy(conn, conn)
		}()
	}
}

/*
test:
socat - TCP:localhost:1234
 */
func main() {
	startEchoServer(Addr)
}
